package com.cup.bddm.api.req;

import com.cup.bddm.config.Config;
import com.cup.bddm.impala.po.User;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;

@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqVo {
	public String token;

	protected Integer id;

	protected String cup_branch_ins_id_cd;
	
	protected String cup_branch_nm;

	protected Integer page = 1;
	
	protected Integer rows = 10;

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getCup_branch_ins_id_cd() {
		return cup_branch_ins_id_cd;
	}

	public void setCup_branch_ins_id_cd(String cup_branch_ins_id_cd) {
		this.cup_branch_ins_id_cd = cup_branch_ins_id_cd;
	}

	public String getCup_branch_nm() {
		return cup_branch_nm;
	}

	public void setCup_branch_nm(String cup_branch_nm) {
		this.cup_branch_nm = cup_branch_nm;
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getRows() {
		return rows;
	}

	public void setRows(Integer rows) {
		this.rows = rows;
	}

	public boolean invalidId() {
		return this.id == null || this.id <= 0;
	}


	/**
	 * 根据token对应的用户重设”分公司机构号“,传到db层
	 */
	public void resetVoIns(User user) {
		if (Config.CUP_INS_ID.equals(user.getCup_branch_ins_id_cd())) {
			this.cup_branch_ins_id_cd = null;
		} else {
			this.cup_branch_ins_id_cd = user.getCup_branch_ins_id_cd();
		}
	}

	/**
	 * 分公司机构号无效返回真，验证完总公司机构号置空
	 */
//	public boolean invalidIns() {
//		boolean flag = false;
//		if (StringUtils.isEmpty(this.cup_branch_ins_id_cd)) {
//			flag = true;
//		}
//		if (CUP_INS_ID.equals(this.cup_branch_ins_id_cd)) {
//			this.cup_branch_ins_id_cd = null;
//		}
//		return flag;
//	}

	/**
	 * 分页对象
	 */
	public PageBounds pager() {
		return new PageBounds(page, rows, true);
	}
}
